package com.intelligentclass.services;

import com.intelligentclass.entity.HomeworkFile;
import com.intelligentclass.entity.HomeworkIntroduce;
import com.intelligentclass.repositories.HomeworkIntroduceRepository;
import org.springframework.stereotype.Service;

@Service
public class HomeworkIntroduceService {

    private HomeworkIntroduceRepository homeworkIntroduceRepository;

    public HomeworkIntroduceService(HomeworkIntroduceRepository homeworkIntroduceRepository) {
        this.homeworkIntroduceRepository = homeworkIntroduceRepository;
    }

    public String getIntroduction(int hid){
        return homeworkIntroduceRepository.getHomeworkIntroduce(hid);
    }

    public HomeworkIntroduce createNewIntroduce(int hid, String introduction){
        HomeworkIntroduce newIntroduce = new HomeworkIntroduce();
        newIntroduce.setHid(hid);
        newIntroduce.setIntroduce(introduction);
        return homeworkIntroduceRepository.save(newIntroduce);
    }
}
